import pygame
from settings import Settings
class Bullet:
    def __init__(self,ai_game):
        #子弹速度和大小
        self.height = Settings().bullet_height
        self.weight = Settings().bullet_weight
        self.speed = Settings().bullet_speed

        self.screen = ai_game.screen
        self.screen_rect = ai_game.screen.get_rect()
        
        #加载子弹图片并获取外接矩形
        self.image = pygame.image.load('code\images\\bullet.bmp')
        self.image = pygame.transform.scale(self.image, (self.height,self.weight))       #改变图片大小
        self.rect = self.image.get_rect()
        self.rect.midtop = ai_game.ship.rect.midtop
        self.fire = False
        self.y=float(self.rect.y)
    
    def blitme(self):
        #指定位置绘制子弹
        if self.fire == True:
            self.screen.blit(self.image,self.rect)